package com.atguigu.chaptar1

object Test44 {
  /**
   * 4、根据指定的规则获取数组中最大元素
   *   Array("zhangsan 30 3500","lisi 25 1800","zhaoliu 29 4500")
   *   规则: 获取工资高的人的信息
   *   结果: "zhaoliu 29 4500"
   */
  def main(args: Array[String]): Unit = {
    val arr = Array("zhangsan 30 3500","lisi 25 1800","zhaoliu 29 4500")
    val func=(x:String)=>{x.split(" ")(2).toInt}
    println(big(arr, _.split(" ")(0).toInt))
  }
  def big(arr:Array[String],func:String=>Int)={
    var tmp: Int = func(arr(0))
    var tmpString = arr(0)
    for(a<-arr){
      val i = func(a)
      if(i>tmp){
        tmp = i
        tmpString=a
      }
    }
    tmpString
  }

}
